#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
#include <QCheckBox>
#include <QGridLayout>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //构建控件 头像、用户名、密码输入框等
    QLineEdit *pUserLineEdit      = new QLineEdit();
    QLineEdit *pPasswordLineEdit  = new QLineEdit();
    QCheckBox *pRememberCheckBox  = new QCheckBox();
    QCheckBox *pAutoLoginCheckBox = new QCheckBox();
    QPushButton *pLoginButton     = new QPushButton();
    QPushButton *pRegisterButton  = new QPushButton();
    QPushButton *pForgetButton    = new QPushButton();

    QObject::connect(pLoginButton,&QPushButton::clicked,this,&Widget::bu_slots);
    pLoginButton->setFixedHeight(30);
    pUserLineEdit->setFixedHeight(30);

    pUserLineEdit->setPlaceholderText(QStringLiteral("QQ号码/手机/邮箱"));
    pPasswordLineEdit->setPlaceholderText(QStringLiteral("密码"));
    pPasswordLineEdit->setEchoMode(QLineEdit::Password);
    pRememberCheckBox->setText(QStringLiteral("记住密码"));
    pAutoLoginCheckBox->setText(QStringLiteral("自动登录"));
    pLoginButton->setText(QStringLiteral("登录"));
    pRegisterButton->setText(QStringLiteral("注册账号"));
    pForgetButton->setText(QStringLiteral("找回密码"));

    QGridLayout *layout = new QGridLayout();
    layout->addWidget(pUserLineEdit,0,1,1,2);
    layout->addWidget(pRegisterButton,0,4);
    layout->addWidget(pPasswordLineEdit,1,1,1,2);
    layout->addWidget(pForgetButton,1,4);
    layout->addWidget(pRememberCheckBox,2,1,1,1,Qt::AlignLeft | Qt::AlignVCenter);
    layout->addWidget(pAutoLoginCheckBox,2,2,1,1,Qt::AlignRight | Qt::AlignVCenter);
    layout->addWidget(pLoginButton,3,1,1,2);
    layout->setHorizontalSpacing(10);
    layout->setVerticalSpacing(10);
    layout->setContentsMargins(10,10,10,10);

    setLayout(layout);

    connect(pLoginButton,&QPushButton::clicked,this,&Widget::bu_slots);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::bu_slots()
{
    qDebug()<<"hello";
}
